package com.itheima.domain.SoulTest;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class QuestionNaireVo implements Serializable {
    private String id;
    private String name;
    private String cover;
    private String level;
    private Integer star;
    private List<WJQuestionVo> questions;
    private Integer isLock = 0;
    private String reportId;

    public QuestionNaireVo setVo(QuestionNaire questionNaire){
        QuestionNaireVo vo = new QuestionNaireVo();
        BeanUtil.copyProperties(questionNaire,vo);
        vo.setId(questionNaire.getId().toHexString());

        List<WJQuestion> questions = questionNaire.getQuestions();
        ArrayList<WJQuestionVo> vos = new ArrayList<>();
        for (WJQuestion question : questions) {
            WJQuestionVo wjQuestionVo = new WJQuestionVo();
            BeanUtil.copyProperties(question,wjQuestionVo);
            wjQuestionVo.setId(question.getId().toHexString());
            vos.add(wjQuestionVo);
        }
        vo.setQuestions(vos);
        return vo;
    }


}
